home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1488 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  46 lines

  1. Path: io.org!jgordon
  2. From: jgordon@io.org (John Gordon MacPherson)
  3. Newsgroups: comp.lang.c
  4. Subject: Help with simple code
  5. Date: 14 Jan 1996 16:22:29 GMT
  6. Organization: Internex Online, Toronto, Ontario, Canada (416 363 3783)
  7. Distribution: world
  8. Message-ID: <4dbak5$oij@ionews.io.org>
  9. NNTP-Posting-Host: kipper.net2.io.org
  10. X-Newsreader: slrn (0.8.0)
  11.  
  12. Can anyone tell me what's wrong with this piece of code? I lifted it
  13. straight from a textbook.
  14.  
  15. Here's the code:
  16.  
  17. /* Calculating compound interest */
  18. #include <stdio.h>
  19. #include <math.h>
  20.  
  21. main()
  22. {
  23.     int year;
  24.     double amount, principal = 1000, rate = 0.5;
  25.  
  26.     printf("%4s%21s\n", "Year", "Amount on deposit");
  27.  
  28.     for (year = 1; year <= 10; year++) {
  29.         amount = principal * pow(1.0 + rate, year);
  30.         printf("%4d%21.2f\n", year, amount);
  31.     }
  32.  
  33.     return 0;
  34. }
  35. ______________________________________________________________
  36.  
  37. and here's the error:
  38.  
  39. In function `main':
  40. undefined reference to `pow'
  41.  
  42. I don't understand. `pow' is a function, not a variable?
  43. Can anyone tell me what's wrong?
  44.  
  45.  
  46.